class Solution {
public:
    ListNode* removeElements(ListNode* head, int val) {
ListNode** h = &head;
        while (*h) {
            if ((*h)->val != val)
                h = &((*h)->next);
            else 
                *h = (*h)->next;
        }
        return head;
    }
};